package cn.kcq.action;

import java.util.HashSet;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

import cn.kcq.entity.SaleOrder;
import cn.kcq.entity.SaleOrderLine;
import cn.kcq.entity.SaleProduct;
import cn.kcq.service.OrderServiceDao;

@Controller
public class ProductAction extends ActionSupport {
	@Autowired
	private OrderServiceDao orderService;

	private SaleOrder item;
	private SaleOrderLine line;
	private List<SaleProduct> prodList;
	private String ceshi;

	public String getCeshi() {
		return ceshi;
	}

	public void setCeshi(String ceshi) {
		this.ceshi = ceshi;
	}

	public List<SaleProduct> getProdList() {
		return prodList;
	}

	public void setProdList(List<SaleProduct> prodList) {
		this.prodList = prodList;
	}

	public SaleOrder getItem() {
		return item;
	}

	public void setItem(SaleOrder item) {
		this.item = item;
	}

	public SaleOrderLine getLine() {
		return line;
	}

	public void setLine(SaleOrderLine line) {
		this.line = line;
	}

	public String showDetail() {
		item = (SaleOrder) ActionContext.getContext().getSession().get("item");
		item.setSaleOrderLines(new HashSet(orderService.getOrderLine(item.getOdrId())));
		prodList = orderService.getProductList();
		for (SaleProduct product : prodList) {
			product.setProdDetail(product.getProdName() + "-" + product.getProdPrice());
		}
		return "showDetail";
	}
}
